import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/index',
    name: 'Index',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../pages/index.vue'),
    children: [
      {
        path: '/home',
        name: '首页',
        component: () => import(/**/ '../views/Home.vue')
      },
      {
        path: '/cart',
        name: '购物车',
        component: () => import('../views/Cart.vue')
      },
      {
        path: '/cate',
        name: '分类',
        component: () => import('../views/Cate.vue')
      },
      {
        path: '/mine',
        name: '个人中心',
        component: () => import('../views/Mine.vue')
      },
      {
        path: '',
        redirect: '/home' 
      }
    ]
  },
  {
    path: '/login',
    name: '登录',
    component: () => import('../pages/Login.vue')
  },
  {
    path: '/register',
    name: '注册',
    component: () => import('../pages/Register.vue')
  },
  {
    path: '/detail',
    name: '详情页',
    component: () => import('../pages/Detail.vue')
  },
  {
    path: '/list',
    name: '商品列表',
    component: () => import('../pages/List.vue')
  },
  {
    path: '/address',
    name: '地址管理',
    component: () => import('../pages/Address.vue')
  },
  {
    path: '/addressedit',
    name: '新增地址',
    component: () => import('../pages/AddressEdit.vue')
  },
  {
    path: '/order',
    name: '确认订单',
    component: () => import('../pages/Order.vue')
  },
  {
    path: '/pay',
    name: '支付订单',
    component: () => import('../pages/Pay.vue')
  },
  {
    path: '*',
    redirect: '/index'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
